<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <a href="http://www.baidu.com">百度</a>

    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
    <script>
        // 获取a标签的href属性
        var href = $('a').attr('href');
        console.log('href', href);

        // 2秒后把百度换成新浪,同时改变它的href地址
        setTimeout(function() {
            $('a').text('新浪');
            $('a').attr('href', 'http://sina.com');
        }, 2000)
    </script>
</body>

</html>